package cn.jsj.dispose;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jsj.object.FrontAssistInfo;
import cn.jsj.pojo.TblLawyAssistant;
import cn.jsj.utils.ProduceJsonData;
import cn.jsj.utils.SysLogger;

/**
 * 查询律师助理信息
 * @author LI
 *
 */
 public class SearchAssistInfo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 // 调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("查询律师助理信息");

		 //获得律师助理姓名
		 String lawyerAssistName=request.getParameter("sAssistName").trim();
		 lawyerAssistName = new String(lawyerAssistName.getBytes("ISO-8859-1"), "utf-8");

		//获得限定条件 从第几条开始，一页显示几条
		int startNumb=Integer.parseInt(request.getParameter("start"));
		int totalNumb=Integer.parseInt(request.getParameter("limit"));

		//调试信息
		cn.jsj.utils.SysLogger.PrintInfo("获得的参数为--->"+lawyerAssistName+"     "+startNumb+totalNumb);

		//传到DB的参数类
		cn.jsj.bgtodb.SearchAssistProperty sap=new cn.jsj.bgtodb.SearchAssistProperty();
		sap.setAssistName(lawyerAssistName);
		sap.setStartNumb(startNumb);
		sap.setTotalNumb(totalNumb);

		//获得这位律师助理的信息
		java.util.List<TblLawyAssistant> assistList=new java.util.LinkedList<TblLawyAssistant>();
		cn.jsj.dao.TblLawyAssistantDAO tlad=new cn.jsj.dao.TblLawyAssistantDAO();
		assistList=tlad.getSearchLaweryAssist(sap);


		//前台律师助理信息对象队列
		java.util.List<FrontAssistInfo> frontLawyerAssistInfo=new java.util.LinkedList<FrontAssistInfo>();

		//改造成前台需要的律师助理信息对象
		cn.jsj.object.rebuild.FrontLawyerAssistRebuild flar=new cn.jsj.object.rebuild.FrontLawyerAssistRebuild();
		for(int i=0;i<assistList.size();i++){
			cn.jsj.object.FrontAssistInfo fai=flar.rebulidAssistInfo(assistList.get(i));
			frontLawyerAssistInfo.add(fai);
		}

		//改造成JSON型数据
		ProduceJsonData pjd=new ProduceJsonData();
	String resultData=	pjd.jsonFromList(frontLawyerAssistInfo,1);

	//调试信息
	SysLogger.PrintInfo(resultData);
	//输出到客户端
	java.io.PrintWriter pw=response.getWriter();
	pw.println(resultData);
	pw.flush();
	}
}